package com.wgy.day32字符流.字符输入流;
/*
使用字节流读取中文文件:
1个中文:GBK:占用2个字节
      UTF-8:占用3个字节
*/

import java.io.FileInputStream;
import java.io.IOException;

public class DemoInputStream {
    public static void main(String[] args) throws IOException {
        show02();

    }

    public static void show01() throws IOException {
        FileInputStream fis = new FileInputStream("D:\\小云\\abc\\b\\b.txt");
        byte[] bytes = new byte[1024];
        int len = 0;
        while ((len = fis.read(bytes)) != -1) {
            System.out.println(new String(bytes));
        }
        for (byte b : bytes) {
            System.out.println(b);
        }
    }



    public static void show02() throws IOException {
        FileInputStream fis = new FileInputStream("D:\\小云\\abc\\b\\b.txt");
        int len = 0;
        while ((len = fis.read()) != -1) {
            System.out.println(/*(char) */len);//无法转换为对应的中文字符,因为一个中文字符对应多个字节,而这种写法只能是一个字节转换为一个字符,
        }
    }
}
